<?php
$this->breadcrumbs=array(
	'综合控制台'=>array($this->pre_module_url.'/index/index'),
	'广告管理'=>array($this->pre_module_url.'/adse/admin'),
	'广告位管理'=>array($this->pre_module_url.'/adzon/admin'),	
);
?>

<div class="hr_10"></div>

<div class="pro_filter c_f">
     <div class="filter f_l">
          <?php $form=$this->beginWidget('CActiveForm', array(
                 'action'=>Yii::app()->createUrl($this->route),
                 'method'=>'get',
          )); ?>
            <span id="menubox" class="cont" align="left"> 选择页面：
                    <?php 
                        echo CHtml::dropDownList('zna_id',$zna_id['1'],Nav::model()->getTopData(),array('class'=>'mr10 s_ipt level_1 w_120','onchange'=>'afterSelect(1,this.value)','id'=>'menuselect1')); 
						echo CHtml::dropDownList('zna_id2',$zna_id['2'],Nav::model()->getChildData($zna_id['1']?$zna_id['1']:-1),array('class'=>'mr10 s_ipt level_1 w_120','onchange'=>'afterSelect(2,this.value)','id'=>'menuselect2')); 
						echo CHtml::dropDownList('zna_id3',$zna_id['3'],Nav::model()->getChildData($zna_id['2']?$zna_id['2']:-1),array('class'=>'mr10 s_ipt level_1 w_120','onchange'=>'afterSelect(3,this.value)','id'=>'menuselect3')); 
					?>
            </span>
            <button class="mem_bgx mem_btn01" type="submit" name="">查找</button>
           <?php $this->endWidget(); ?>
      </div>
</div>


<table class="list_table list_table2" width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <th width="" class="pl15">广告位位置</th>
            <th width="13%">广告位ID</th>
            <th width="15%">已传广告数/最大显示数</th>
            <th width="20%">所属页面</th>
            <th width="25%">操作</th>
        </tr>
</table>


<?php $this->Widget('zii.widgets.CListView', array(
	'dataProvider'=>$model->search(),
    'itemView'=>'_admin',
	'itemsTagName'=>'table',
	'itemsOptions'=>array('class'=>'list_table list_table2','width'=>'100%','cellpadding'=>0,'cellspacing'=>0),
	'selectAll'=>array('ids[]','id[]'),
    'artLink'=>array(
        	//批量删除
        	array(Yii::t('adm','Delete All'),$this->pre_module_url.'/adzone/batchChange','确认批量删除！'),
     ),
)); ?>


<script>
	function afterSelect(level,menuid){
		$('#menuselect'+level).nextAll().html('<option value="0">请选择</option');
		menuid = parseInt(menuid)==0 ? -1 : menuid;
		$.getJSON("/manage/nav/getchildmenu", { menuid: menuid, level: level }, function(data){
			if(data.amount){
				var nextLevel=parseInt(data.level)+1;
				var next = '';
				$.each(data.items, function(i,item){
					next += '<option value="'+i+'">'+item+'</option>';
				});
				next += '';
				$('#menuselect'+nextLevel).html(next);
			}
		});
	}
	//显示广告调用代码
	//id:广告位id
	//type:1图片广告2swf广告
	function showCode(id,type) {
		art.dialog({ padding: 0, title: '广告位调用代码', content: type==1?
		'<div class="w_790" style="height:500px;padding:10px;text-align:center"><strong>javascript调用代码</strong><br/>(若需关联分类，请将url中的catid参数0替换为当前分类id)<br/><textarea style="width:750px;height:50px;text-align:center"><?php echo htmlspecialchars('<script language="javascript" src="'.Yii::app()->createAbsoluteUrl('api/adshow').'/zid/\'+id+\'/catid/0"></script>');?>\
		</textarea>\
		<br/>\
		<br/>\
		<strong>PHP调用代码</strong><br/>(若需关联分类，参数$cid替换为当前分类id)<br/>\
		<textarea style="width:750px;height:200px;">\
		<?php echo htmlspecialchars('$adzone = Adzone::model()->getData(\'+id+\',$cid=0);\n\
		$html = \\\'<div>\\\';\n\
		foreach($adzone[\\\'ads\\\'] as $key=>$value){\n\
			$html .= \\\'<li style="list-style:none"><a href="\\\'.$value[\\\'zds_url\\\'].\\\'"><img height="\\\'.$adzone[\\\'zdz_height\\\'].\\\'" \n\
			width="\\\'.$adzone[\\\'zdz_width\\\'].\\\'" src="\\\'.$value[\\\'zds_file_url\\\'].\\\'" style="border:0px;"></a></li>\\\';\n\
		}\n\
		$html .= \\\'</div>\\\';\n\
		echo $html;');?>
		</textarea>\
		</div>\
		'
		:
		'<div class="w_790" style="height:500px;padding:10px;text-align:center"><strong>javascript调用代码</strong><br/>(若需关联分类，请将url中的catid参数0替换为当前分类id)<br/><textarea style="width:750px;height:50px;text-align:center"><?php echo htmlspecialchars('<script language="javascript" src="'.Yii::app()->createAbsoluteUrl('api/adshow').'/zid/\'+id+\'/catid/0"></script>');?>\
		</textarea>\
		<br/>\
		<br/>\
		<strong>PHP调用代码</strong><br/>(若需关联分类，参数$cid替换为当前分类id)<br/>\
		<textarea style="width:750px;height:320px;">\
		<?php echo htmlspecialchars('$adzone = Adzone::model()->getData(\'+id+\',$cid=0);\n\
		$html = \\\'<div>\\\';\n\
		foreach($adzone[\\\'ads\\\'] as $key=>$value){\n\
			$html .= "<li style=\\\'list-style:none\\\'><object classid=\\\'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\\\' \n\
			width=\\\'".$adzone[\\\'zdz_width\\\']."\\\' height=\\\'".$adzone[\\\'zdz_height\\\']."\\\' id=\\\'FlashAD_".$value[\\\'zds_id\\\']."\\\' \n\
			codebase=\\\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\\\'>";\n\
			$html .= "<param name=\\\'movie\\\' value=\\\'".$value[\\\'zds_file_url\\\']."\\\' />";\n\
			$html .= "<param name=\\\'quality\\\' value=\\\'autohigh\\\' />";\n\
			$html .= "<param name=\\\'wmode\\\' value=\\\'opaque\\\'/>";\n\
			$html .= "<embed src=\\\'".$value[\\\'zds_file_url\\\']."\\\' quality=\\\'autohigh\\\' wmode=\\\'opaque\\\' name=\\\'flashad\\\' swliveconnect=\\\'TRUE\\\' \n\
			pluginspage=\\\'http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\\\' \n\
			type=\\\'application/x-shockwave-flash\\\' width=\\\'".$adzone[\\\'zdz_width\\\']."\\\' height=\\\'".$adzone[\\\'zdz_height\\\']."\\\'></embed>";\n\
			$html .= "</object></li>";\n\
		}\n\
		$html .= \\\'</div>\\\';\n\
		echo $html;');?>
		</textarea>\
		</div>\
		'
		, lock: true });
	} 
</script>
